﻿namespace Ngs.Data
{
    using System.Linq;

    #region IStorageStrategy
    /// <summary>
    /// Main inteface for defining data operations.
    /// </summary>
    public interface IStorageStrategy
    {
        IQueryable Queryable();

        object Create(object resource);

        void Delete(object resource);

        void Save(object resource);
    } 
    #endregion

    /// <summary>
    /// Main inteface for defining data operations. 
    /// </summary>
    /// <typeparam name="T">The type to perform the data operation on.</typeparam>
    public interface IStorageStrategy<T> : IStorageStrategy where T : class
    {
        /// <summary>
        /// This is a safe method, without side effects and idempotent.
        /// </summary>
        /// <remarks>SHOULD NOT have the significance of taking an action other than retrieval.</remarks>
        /// <returns></returns>
        IDataQuery<T> Query();

        /// <summary>
        /// Persists and echos the item saved.
        /// </summary>
        /// <remarks>Each call persists new objects, and thus should not be considered idempotent.</remarks>
        /// <param name="resource"></param>
        /// <returns></returns>
        T Create(T resource);

        /// <summary>
        /// Deletes existing item from the repository.
        /// </summary>
        /// <param name="resource"></param>
        void Delete(T resource);

        /// <summary>
        /// Persists the modifications into the store.
        /// </summary>
        /// <param name="resource"></param>
        void Save(T resource);
    }
}
